package com.diy.sigmund.diycommon.designpatterns.command;

/**
 * @author ylm-sigmund
 * @since 2022/2/9 14:35
 */
public class CeilingFanUndoCommand implements Command {

    CeilingFan ceilingFan;
    int preSpeed;

    public CeilingFanUndoCommand(CeilingFan ceilingFan) {
        this.ceilingFan = ceilingFan;
    }

    @Override
    public void execute() {

    }

    @Override
    public void undo() {
        if (preSpeed == CeilingFan.OFF) {
            ceilingFan.off();
        } else if (preSpeed == CeilingFan.LOW) {
            ceilingFan.low();
        } else if (preSpeed == CeilingFan.MEDIUM) {
            ceilingFan.medium();
        } else if (preSpeed == CeilingFan.HIGH) {
            ceilingFan.high();
        }
    }
}
